
// import { createPinia } from 'pinia'
// import { createUnistorage } from '@/common/pinia-plugin-unistorage_0.0.8/index.js'
// const store = createPinia()
// store.use(createUnistorage())



// export default store


import { createPinia } from 'pinia';
// import piniaPersist from 'pinia-plugin-persist-uni';
import {createUnistorage } from '@/common/pinia-plugin-unistorage_0.0.8/index.js'
// 自动注入所有pinia模块
const files = import.meta.glob('./*.js', { eager: true });

const modules = {};
Object.keys(files).forEach((key) => {
  modules[key.replace(/(.*\/)*([^.]+).*/gi, '$2')] = files[key].default;
});

export const setupPinia = (app) => {
  const pinia = createPinia();
  pinia.use(createUnistorage());

  app.use(pinia);
};

export default (name) => {
  return modules[name]();
};
